package cn.pacom.admin.core.tools.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.thingsboard.rest.client.RestClient;

/**
 * @author zhanghl
 * @Date 2020/7/27 13:29
 */
@Configuration
public class ThingsboardRestConfig {
  @Value("${pacom.iot-tools.username:sysadmin@thingsboard.org}")
  private String username;
  @Value("${pacom.iot-tools.password:sysadmin}")
  private String password;
  @Value("${pacom.iot-tools.base-uri:http://test-iot-tools.pacom.cn}")
  private String baseUrl;

  @Bean
  public RestClient restClient() {
    RestClient restClient = new RestClient(baseUrl);
    restClient.login(username, password);
    return restClient;
  }

  public String getBaseUrl() {
    return baseUrl;
  }
}
